#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>

#include "global.h"
#include "directoryentry.h"
#include "inode.h"
#include "superblock.h"

/*
extern int FileSystemInitialization(unsigned long, unsigned long);
extern int mkdir(unsigned long , char *);
extern int cd(char *);
*/

int main(int argc, char* argv[])
{
		iptr=0;
		int rvalue;
		char buffer[20];
		char commandarg[14];
		unsigned long arg1 = 0, arg2 = 0;
		int i=0;
		strcpy(buffer, argv[0]);
		arg1=atoi(argv[1]);
		arg2=atoi(argv[2]);

	  if (argc!=3)
		{
			printf("Arguements mismatch\n");
			exit(1);
		}

		if(!strcmp(buffer, "./init"))
			{
				rvalue=FileSystemInitialization(arg1, arg2);
				/*Once you initialize your FS you close your file descriptor.
				Hence open it again while you try to execute commands.*/
			}
		else
			{
				printf("Please initialize the File System\n");
			}
		while(1)
		{
			scanf("%s", buffer);
			if(!strcmp(buffer, "mkdir"))
				{
					scanf("%s", commandarg);
					rvalue=mkdir(arg2, commandarg);
				}
		  else if(!strcmp(buffer, "cd"))
				{
					scanf("%s", commandarg);
					rvalue=cd(commandarg);
				}
			else
				{
					printf("Invalid command\n");
					exit(1);
				}
		}
}
